<template>
	<view :class="['loading', visible ? 'active' : '']">
		<view class="loading-content">
			<view class="loading-tips"><text>{{text}}</text></view>
			<view class="loading-progress">
				<view class="loading-progressing" :style="{width: `${progress}%`}"></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: [
			'visible',
			'text',
			'progress'
		]
	}
</script>

<style lang="scss" scoped>
	.loading {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		right: 0;
		display: none;
		justify-content: center;
		align-items: center;
		z-index: 1000;
		background-color: rgba(0, 0, 0, .4);
		animation: maskShow 300ms;
		&.active {
			display: flex;
		}
		.loading-content {
			background-color: #fff;
			border-radius: 20rpx;
			width: 80%;
			padding: 60rpx;
			box-sizing: border-box;
			.loading-tips {
				text-align: center;
				text {
					font-size: 32rpx;
					color: #000;
				} 
			}
			.loading-progress {
				width: 100%;
				height: 10rpx;
				background-color: #dcdcdc;
				border-radius: 6rpx;
				overflow: hidden;
				margin-top: 40rpx;
				.loading-progressing {
					height: 100%;
					background: -webkit-linear-gradient(left, #00fcde, #00bdfe);
					background: linear-gradient(left, #00fcde, #00bdfe);
				}
			}
		}
	}
	@keyframes maskShow {
		from {
			opacity: 0;
		}
	
		to {
			opacity: 1;
		}
	}
</style>
